package com.syy.spider.service.impl;

import com.syy.spider.dao.OtherInfoMapper;
import com.syy.spider.pojo.NoticeDisplay;
import com.syy.spider.pojo.NoticeGet;
import com.syy.spider.service.OtherInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@Service
public class OtherInfoServiceImpl implements OtherInfoService {
    @Autowired
    private OtherInfoMapper otherInfoMapper;
    @Override
    public List<NoticeDisplay> getNotice() {
        List<NoticeDisplay> noticeDisplays = new ArrayList<>();
        List<NoticeGet> notice = otherInfoMapper.getNotice();
        notice.forEach(var->{
            NoticeDisplay noticeDisplay = new NoticeDisplay();
            noticeDisplay.setId(var.getId());
            noticeDisplay.setCon(var.getCon());
            noticeDisplay.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(var.getDate()));
            noticeDisplay.setViews(var.getViews());
            noticeDisplay.setTitle(var.getTitle());
            noticeDisplays.add(noticeDisplay);
        });
        return noticeDisplays;
    }
}
